package uk.ac.aber.Blockmation.Actions;

import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;

import javax.swing.AbstractAction;

import uk.ac.aber.Blockmation.MainFrame;

/**
 * 
 * @author tom, aron
 */

public class ActionPasteFrame extends AbstractAction {
	
    private MainFrame mainFrame;
    private String path = "../icons/Paste.gif";

    public ActionPasteFrame(MainFrame mainFrame) {
        super("Paste Frame"); 
        this.mainFrame = mainFrame;
        
        // the below from settings class file or?!
        //putValue(SHORT_DESCRIPTION, tooltip);  // Will appear as tooltip text.
        //putValue(MNEMONIC_KEY, new Integer(mnemonic));
        
    }
        
    public void actionPerformed(ActionEvent e) {
        
    	BufferedImage copy;
        
    	if ( (copy = mainFrame.getCopiedFrame()) != null) {
            
    		mainFrame.getMovieModel().setFrame(mainFrame.getCurrentFrameIndex(), 
    				copy);
    		mainFrame.getPad().setImage( copy );
                mainFrame.getCenterBottomPanel().updateCurrentThumb();
                
    	} else {
    		System.err.println("Copy frame first to paste!");
        }
        
    }
    
    public void setImage () {
        CreateImageIcon createImageIcon = new CreateImageIcon();
        putValue(SMALL_ICON, createImageIcon.create(path));
    }
    
}
